Title: Replication File for "How do past repression and indoctrination affect redistributive preferences?"
Author: Lars Pelke
Correspondence: Lars Pelke, Heidelberg University (lars.pelke@ipw.uni-heidelberg.de)
Date: March 22th, 2021

Required Software: R and RStudio (4.0 or Above). 
Additional required software packages and libraries are specified in the replication code.

Overview: These files replicate all analyses in Lars Pelke (2021), "How do past repression and indoctrination afftec redistributive preferences".
To replicate all analyses and figures, download all data files to a folder entitled "~/data", create a folder entitled "~/MacroData", a folder entitled "~/MircoData" and create a 
folder entitled "~/Output" (with subfolder "~/data/margins" in the same directory. In the folder "Output" create a folders entitles "~/Output/government_resp", "~/Output/income_equality", 
"~/Output/indoctrination_mechanism", and "~/Output/without_imp". Please create the following additional folders: "~/data/government_resp_data", "~/data/income_equality_data", 
"~/data/indoctrination_mechanisms"
Note that all data wrangling were proceeded in RStudio, while all HAPC models and statistical analyses were implemented in STATA16. 

To replicate the data wrangling process follow the instructions below:
- Prepare micro level data in folder "~/MircoData" and run all scripts stored in the folder ("01_wvs_data_prepration.R" to "06_merge_mirco_data.R") 
- Prepare macro level data in folder "~/MacroData" and run the following script stored in the folder ("01_data_preparation_macrodata.R") 
- Prepare merged dataset by running "01_merge_mirco_macro.R" stored in the main folder
- Prepare multiple imputated datasets for the merged dataset by running "02_prepare_MI_for_STATA.R"
- Prepare datasets for additional robustness analyses by running "03_prepare_data_robustness_government_resp.R" to "06_prepare_data_robustness_indoctrination_mechanisms.R"

To replicate all analyses in the manuscript and supplementary appendix follow the instruction here:
- run "01_analyses_main_paper.do" to replicate the main analyses presented in the paper
- run "02_robustness_main_models_additional_control_variables.do" to replicate additional robustness tests presented in the Supplementary Appendix
- run "03_robustness_government_resp.do" to replicate additional robustness tests presented in the Supplementary Appendix
- run "04_robustness_income_equality.do" to replicate additional robustness tests presented in the Supplementary Appendix
- run "05_robustness_without_imputation.do" to replicate additional robustness tests without multiple imputated datasets presented in the Supplementary Appendix
- run "06_robustness_indoctrination_mechanisms.do" to replicate additional robustness tests presented in the Supplementary Appendix. Figures presented in the main paper. 

To directly replicate the main analysis, please use "01_analyses_main_paper.do". Prepared datasets, entitled "data/data1.dta" to ""data/data10.dta"" are provided in the replication folder "data". 
All additional datasets are not provided in the replication folder but can be stored by running the above defined R codes. 

%%%%%%%%%%%%%% Replication Code (relative path "~/calculations") %%%%%%%%%%%%%%

01_data_wrangling
Replicates the data wrangling process in the article. In addition, it compiles data need fored subsequent analysis. 

02_main_models
Replicates the main anayslis in the article. You can use this files directly by prepared datasets (vdem_merged.rds and vdem_merged_spaw.rds)
or you can build the datasets with the 01_data_wrangling.R file. 

03_robustness
Replicates all robustness test in the Supplementary Appendix. 

04_Figures
Replicates additional figures in the Supplementary Appendix.


%%%%%%%%%%%%%% Data Files (relative path "~/data") %%%%%%%%%%%%%%

Replication data for data wrangling (are included in the data folder): 
- vdem_9 folder: Varieties of Democracy Version 9, Coppegde et al. 2019 (Creative Commons Attribution-ShareAlike License)
- cow folder: Correlates of War Dataset (https://correlatesofwar.org/data-sets/national-material-capabilities) 
- Solt 2019 SWIID 8.0 folder: SWIID Dataset Version 8.0 (CC0 - "Public Domain Dedication")
- Solt 2019 SWIID 8.2 folder: SWIID Dataset Version 8.2 (CC0 - "Public Domain Dedication")
- sp_data folder: Replication data for "Gamning democracy: Elite Dominance during Transiton and the Prospect for redistirbution" (http://faculty.washington.edu/vmenaldo/Journal%20Supplements/AMGaming_DATA.csv)
- SPAW Rasmussen 2016: Social Policies around the World Dataset (DOI: 10.13140/RG.2.1.2383.7842 and https://journals.sagepub.com/doi/suppl/10.1177/0010414017710265/suppl_file/CPS_replication_Final.dta)
- world_bank_data: World Dank Data on Manufacturing Sector (Creative Commons Attribution 4.0 International License) 


%%%%%%%%%%%%%% Output Files (relative path "~/output") %%%%%%%%%%%%%%

Store outputs, such as Figures and Marginal Plots. All Latex-tables are directly implemented in the R File. 